<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    /**
     * forEach函数
     * arr.forEach(function(currentValue,index,arr){})
    */
       //写入五行四列的表格 将贴子数组中的数据填充到单元格中
    var arr = [
        ["第2条帖子","a","第2条帖子写入五行四列的表格 将贴子数组中的数据填充到单元格中","2011-02-14"],
        ["第4条帖子","c","第4条帖子写入五行四列的表格 将贴子数组中的数据填充到单元格中","2011-02-01"],
        ["第3条帖子","b","第3条帖子写入五行四列的表格 将贴子数组中的数据填充到单元格中","2011-02-23"],
        ["第1条帖子","c","第1条帖子写入五行四列的表格 将贴子数组中的数据填充到单元格中","2011-02-08"],
        ["第5条帖子","b","第5条帖子写入五行四列的表格 将贴子数组中的数据填充到单元格中","2011-02-18"]
    ];
    var borderWidth = 1;
    var tableWidth = 400;
    var tableHeight =400;
    document.write("<table border= '" + borderWidth + "' height='"+ tableHeight +"' width='"+ tableWidth +"'>");
    function createList(arr){
        arr.forEach(function(el,i,arr1){
            document.write("<tr>"); 
            el.forEach(function(val,j,arr2){
                document.write("<td>");
                if(j!=2){
                    document.write(val);
                }else{   
                    document.write(val.slice(0,5)+"······");    
                }
                document.write("</td>"); 
            })
                
                
            document.write("</tr>");   
        })
            
    }
    createList(arr);
    document.write("</table>");
</script>
</html>